package com.dawn.module.hospital.service;

import com.dawn.framework.common.pojo.CommonResult;
import com.dawn.framework.common.util.http.HttpUtils;
import com.dawn.module.hospital.controller.app.pub.vo.PriceReqVO;
import com.dawn.module.hospital.enums.BHConstants;
import com.dawn.module.hospital.enums.ErrorCodeConstants;
import com.dawn.module.hospital.util.ChineseCharToEnUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @description:
 * @author: cnsu-cmh
 * @time: 2024/8/8 18:06
 */
@Slf4j
@Service
public class PubService extends BHService {

    @Resource
    private StringRedisTemplate stringRedisTemplate;

    @Autowired
    private PatientService patientService;

    @Autowired
    private EhealthService ehealthService;

    public CommonResult price(PriceReqVO reqVO) {
        String code = ChineseCharToEnUtils.getFirstSpell(reqVO.getKeywords());//查询名称

        Map args = new HashMap();//his分别查询药品
        args.put("hisProvider",BHConstants.HIS_PROVIDER);
        args.put("spelCode",code.toUpperCase());

        CommonResult result = CommonResult.error(ErrorCodeConstants.BH_ERROR.getCode(), "未查询到数据");
        if("YP".equals(reqVO.getType())){
            args.put("feeItem","1");//1—药品，2—收费
            result = HttpUtils.getHttp(getHisServerUri() + BHConstants.HIS_GET_DRUGS_QUERY.getValue(), args);
            return result;
        }else if("SFXM".equals(reqVO.getType())){
            args.put("feeItem","2");//1—药品，2—收费
            result = HttpUtils.getHttp(getHisServerUri() + BHConstants.HIS_GET_DRUGS_QUERY.getValue(), args);
        }
        return result;
    }


}
